package com.woniuxy.his.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniuxy.his.entity.Patient;
import com.woniuxy.his.exception.ReturnNoResultExceptionHandle;
import com.woniuxy.his.mapper.PatientMapper;
import com.woniuxy.his.service.IPatientService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.his.vo.PatientByCheckeIdVo;
import com.woniuxy.his.vo.PatientByprescriptionIdVo;
import com.woniuxy.his.vo.PayOfPrescriptionVo;
import com.woniuxy.his.vo.GuaHaoVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * <p>
 * 病人表 服务实现类
 * </p>
 *
 * @author Lucas
 * @since 2021-08-24
 */
@Service
public class PatientServiceImpl extends ServiceImpl<PatientMapper, Patient> implements IPatientService {

    @Resource
    private PatientMapper patientMapper;

    @Override//项目划价中根据挂号查询病人信息
    public GuaHaoVo searchPatientByProject(Integer input) {
        GuaHaoVo patient = patientMapper.searchPatientByProject(input);
        return patient;
    }


    @Override
    public IPage<PayOfPrescriptionVo> findPatientByPageAndStatu(String isGiveMedicine, Integer current, Integer pageSize, Date startTime, Date stopTime) {
        IPage page = new Page(current, pageSize);
        IPage patientByPageAndStatu = patientMapper.findPatientByPageAndStatu(page, isGiveMedicine, startTime, stopTime);
        return patientByPageAndStatu;
    }

    @Override
    public PatientByprescriptionIdVo getMsgOfOne(Integer prescriptionId) {
        PatientByprescriptionIdVo msgOfOne = patientMapper.getMsgOfOne(prescriptionId);
        if (msgOfOne == null) {
            throw new ReturnNoResultExceptionHandle();
        }
        return msgOfOne;
    }

    @Override
    public PatientByCheckeIdVo getMsgOfOneByCheckId(Integer checkId) {
        PatientByCheckeIdVo msgOfOneByCheckId = patientMapper.getMsgOfOneByCheckId(checkId);
        if (msgOfOneByCheckId == null) {
            throw new ReturnNoResultExceptionHandle();
        }
        return msgOfOneByCheckId;
    }
}
